package com.robot.topology.main;

import java.util.ArrayList;
import java.util.List;

import com.robot.topology.core.GeneralAlgorithm;
import com.robot.topology.graph.domain.Edge;
import com.robot.topology.graph.domain.Graph;
import com.robot.topology.graph.domain.Vertex;
import com.robot.topology.tools.GraphTools;

public class MainDeterministicRobot {

	public static void main(String[] args) {

		String strategyToImplement = args[0].toString();
		//BM, INC,SHORT		
		
		//Self instantiate
		MainDeterministicRobot main = new MainDeterministicRobot();

		// Create graph
		Graph graphToExplore=main.buildGraph();
		try{
			GeneralAlgorithm.deterministicAlgorithm(graphToExplore, strategyToImplement);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}


	public Graph buildGraph (){

		//Create the vertices
		Vertex vertexR1 = new Vertex("R1");
		Vertex vertexR3 = new Vertex("R3");
		Vertex vertexR4 = new Vertex("R4");
		Vertex vertexC1 = new Vertex("C1");
		Vertex vertexC2 = new Vertex("C2");

		//Create the list of Vertices
		List<Vertex> listVertex = new ArrayList<Vertex>();
		listVertex.add(vertexR1);
		listVertex.add(vertexR3);
		listVertex.add(vertexR4);
		listVertex.add(vertexC1);
		listVertex.add(vertexC2);

		//Get the initial weight at random
		Double initialWeight=GraphTools.initializeWeightAtRandom();
		System.out.println(initialWeight);
		//Create the edges
		Edge edgeR1C1 = new Edge("R1C1", vertexR1, vertexC1, (double)1);
		Edge edgeC1R3 = new Edge("C1R3", vertexC1, vertexR3, initialWeight);
		Edge edgeR3C2 = new Edge("R3C2", vertexR3, vertexC2,(double)1);
		Edge edgeC1C2 = new Edge("C1C2", vertexC1, vertexC2, initialWeight);
		Edge edgeC2R4 = new Edge("C2R4", vertexC2, vertexR4, (double)1);

		//Edges in a list
		List<Edge> listEdge = new ArrayList<Edge>();
		listEdge.add(edgeR1C1);
		listEdge.add(edgeC1R3);
		listEdge.add(edgeR3C2);
		listEdge.add(edgeC1C2);
		listEdge.add(edgeC2R4);

		// Create the graph
		Graph theGraph = new Graph(listVertex, listEdge);
		// Set the initial and goal verteces
		theGraph.setInitialVertex(vertexR1);
		theGraph.setGoalVertex(vertexR4);

		return theGraph;
	}


}
